//
//  VisitorTableViewController.swift
//  weibo27
//
//  Created by 董浩 on 16/4/19.
//  Copyright © 2016年 donghao. All rights reserved.
//

import UIKit

class VisitorTableViewController: UITableViewController {

    //用户登录标记
    private var userLogon = false
    //吧visitorView定义为属性
    /// 访客视图
    lazy var visitorView: VisitorView? = VisitorView()
    
    override func loadView() {
//        super.loadView()
        
        userLogon ? super.loadView() : setupLogon()
        
    }
/// 设置访客视图行数
    private func setupLogon() {
    
        //假设登录失败，替换根视图
        visitorView = VisitorView()
       
        visitorView?.delegate = self
        view = visitorView
        
        //设置导航栏按钮
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorViewDidRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "visitorViewDidLogin")

    }
}


extension VisitorTableViewController:visitorViewDelegate {

    func visitorViewDidRegister() {
        print("注册")
    }

    func visitorViewDidLogin() {
        print("登录")
    }


}

